home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 322 / compsrc4 / toplev.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-20  |  41.6 KB  |  1,632 lines

  1. /* Top level of GNU C compiler
  2.    Copyright (C) 1987, 1988 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY.  No author or distributor
  8. accepts responsibility to anyone for the consequences of using it
  9. or for whether it serves any particular purpose or works at all,
  10. unless he says so in writing.  Refer to the GNU CC General Public
  11. License for full details.
  12.  
  13. Everyone is granted permission to copy, modify and redistribute
  14. GNU CC, but only under the conditions described in the
  15. GNU CC General Public License.   A copy of this license is
  16. supposed to have been given to you along with GNU CC so you
  17. can know your rights and responsibilities.  It should be in a
  18. file named COPYING.  Among other things, the copyright notice
  19. and this notice must be preserved on all copies.  */
  20.  
  21.  
  22. /* This is the top level of cc1.
  23.    It parses command args, opens files, invokes the various passes
  24.    in the proper order, and counts the time used by each.
  25.    Error messages and low-level interface to malloc also handled here.  */
  26.  
  27. #include "config.h"
  28. #include <stdio.h>
  29.  
  30. #ifdef atarist
  31. #include <signal.h>
  32. #include <types.h>
  33. #include <stat.h>
  34.  
  35. extern long _stksize = 500000;        /* enough to compile -O gas */
  36.  
  37. #else
  38.  
  39. #include <signal.h>
  40.  
  41. #include <sys/types.h>
  42. #include <sys/stat.h>
  43.  
  44. #ifdef USG
  45. #include <sys/param.h>
  46. #include <sys/times.h>
  47. #include <time.h>   /* Correct for hpux at least.  Is it good on other USG?  */
  48. #else
  49. #ifndef VMS
  50. #include <sys/time.h>
  51. #include <sys/resource.h>
  52. #endif
  53. #endif
  54.  
  55. #endif        /* atarist */
  56.  
  57. #include "tree.h"
  58. #include "c-tree.h"
  59. #include "rtl.h"
  60. #include "flags.h"
  61.  
  62. extern int yydebug;
  63.  
  64. extern FILE *finput;
  65.  
  66. extern void init_lex ();
  67. extern void init_decl_processing ();
  68. extern void init_tree ();
  69. extern void init_rtl ();
  70. extern void init_optabs ();
  71. extern void init_reg_sets ();
  72. extern void dump_flow_info ();
  73. extern void dump_local_alloc ();
  74.  
  75. void rest_of_decl_compilation ();
  76. void error ();
  77. void error_with_file_and_line ();
  78. void set_target_switch ();
  79.  
  80. /* Bit flags that specify the machine subtype we are compiling for.
  81.    Bits are tested using macros TARGET_... defined in the tm-...h file
  82.    and set by `-m...' switches.  */
  83.  
  84. int target_flags;
  85.  
  86. /* Name of current original source file (what was input to cpp).
  87.    This comes from each #-command in the actual input.  */
  88.  
  89. char *input_filename;
  90.  
  91. /* Name of top-level original source file (what was input to cpp).
  92.    This comes from the first #-command in the actual input.  */
  93.  
  94. char *main_input_filename;
  95.  
  96. /* Current line number in real source file.  */
  97.  
  98. extern int lineno;
  99.  
  100. /* FUNCTION_DECL for function now being parsed or compiled.  */
  101.  
  102. extern tree current_function_decl;
  103.  
  104. /* Name to use as base of names for dump output files.  */
  105.  
  106. char *dump_base_name;
  107.  
  108. /* Flags saying which kinds of debugging dump have been requested.  */
  109.  
  110. int rtl_dump = 0;
  111. int rtl_dump_and_exit = 0;
  112. int jump_opt_dump = 0;
  113. int cse_dump = 0;
  114. int loop_dump = 0;
  115. int flow_dump = 0;
  116. int combine_dump = 0;
  117. int local_reg_dump = 0;
  118. int global_reg_dump = 0;
  119. int jump2_opt_dump = 0;
  120.  
  121. /* 1 => write gdb debugging output (using symout.c).  -g
  122.    2 => write dbx debugging output (using dbxout.c).  -G  */
  123.  
  124. enum debugger write_symbols = NO_DEBUG;
  125.  
  126. /* Nonzero means do optimizations.  -opt.  */
  127.  
  128. int optimize = 0;
  129.  
  130. /* Nonzero for -fforce-mem: load memory value into a register
  131.    before arithmetic on it.  This makes better cse but slower compilation.  */
  132.  
  133. int flag_force_mem = 0;
  134.  
  135. /* Nonzero for -fforce-addr: load memory address into a register before
  136.    reference to memory.  This makes better cse but slower compilation.  */
  137.  
  138. int flag_force_addr = 0;
  139.  
  140. /* Nonzero for -fdefer-pop: don't pop args after each function call;
  141.    instead save them up to pop many calls' args with one insns.  */
  142.  
  143. int flag_defer_pop = 1;
  144.  
  145. /* Nonzero for -ffloat-store: don't allocate floats and doubles
  146.    in extended-precision registers.  */
  147.  
  148. int flag_float_store = 0;
  149.  
  150. /* Nonzero for -fcombine-regs:
  151.    allow instruction combiner to combine an insn
  152.    that just copies one reg to another.  */
  153.  
  154. int flag_combine_regs = 0;
  155.  
  156. /* Nonzero for -fwritable-strings:
  157.    store string constants in data segment and don't uniquize them.  */
  158.  
  159. int flag_writable_strings = 0;
  160.  
  161. /* Nonzero means don't put addresses of constant functions in registers.
  162.    Used for compiling the Unix kernel, where strange substitutions are
  163.    done on the assembly output.  */
  164.  
  165. int flag_no_function_cse = 0;
  166.  
  167. /* Nonzero for -fomit-frame-pointer:
  168.    don't make a frame pointer in simple functions that don't require one.  */
  169.  
  170. int flag_omit_frame_pointer = 0;
  171.  
  172. /* Nonzero to inhibit use of define_optimization peephole opts.  */
  173.  
  174. int flag_no_peephole = 0;
  175.  
  176. /* Nonzero means `char' should be signed.  */
  177.  
  178. int flag_signed_char;
  179.  
  180. /* Nonzero means allow type mismatches in conditional expressions;
  181.    just make their values `void'.   */
  182.  
  183. int flag_cond_mismatch;
  184.  
  185. /* Nonzero means don't recognize the keyword `asm'.  */
  186.  
  187. int flag_no_asm;
  188.  
  189. /* Nonzero means warn about implicit declarations.  */
  190.  
  191. int warn_implicit;
  192.  
  193. /* Nonzero means warn about function definitions that default the return type
  194.    or that use a null return and have a return-type other than void.  */
  195.  
  196. int warn_return_type;
  197.  
  198. /* Nonzero means do some things the same way PCC does.  */
  199.  
  200. int flag_traditional;
  201.  
  202. /* Nonzero means all references through pointers are volatile.  */
  203.  
  204. int flag_volatile;
  205.  
  206. /* Nonzero means do stupid register allocation.  -noreg.
  207.    This and `optimize' are controlled by different switches in cc1,
  208.    but normally cc controls them both with the -O switch.  */
  209.  
  210. int obey_regdecls = 0;
  211.  
  212. /* Don't print functions as they are compiled and don't print
  213.    times taken by the various passes.  -quiet.  */
  214.  
  215. int quiet_flag = 0;
  216.  
  217. /* Don't print warning messages.  -w.  */
  218.  
  219. int inhibit_warnings = 0;
  220.  
  221. /* Do print extra warnings (such as for uninitialized variables).  -W.  */
  222.  
  223. int extra_warnings = 0;
  224.  
  225. /* Number of error messages and warning messages so far.  */
  226.  
  227. int errorcount = 0;
  228. int warningcount = 0;
  229.  
  230. /* Nonzero if generating code to do profiling.  */
  231.  
  232. int profile_flag = 0;
  233.  
  234. /* Nonzero for -pedantic switch: warn about anything
  235.    that standard C forbids.  */
  236.  
  237. int pedantic = 0;
  238.  
  239. /* Nonzero means `$' can be in an identifier.
  240.    See cccp.c for reasons why this breaks some obscure ANSI C programs.  */
  241.  
  242. #ifndef DOLLARS_IN_IDENTIFIERS
  243. #define DOLLARS_IN_IDENTIFIERS 0
  244. #endif
  245. int dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
  246.  
  247. /* Nonzero for -finline-functions: ok to inline functions that look like
  248.    good inline candidates.  */
  249.  
  250. int flag_inline_functions;
  251.  
  252. /* Nonzero for -fkeep-inline-functions: even if we make a function
  253.    go inline everywhere, keep its defintion around for debugging
  254.    purposes.  */
  255.  
  256. int flag_keep_inline_functions;
  257.  
  258. /* Name for output file of assembly code, specified with -o.  */
  259.  
  260. char *asm_file_name;
  261.  
  262. /* Name for output file of GDB symbol segment, specified with -symout.  */
  263.  
  264. char *sym_file_name;
  265.  
  266. /* Output files for assembler code (real compiler output)
  267.    and debugging dumps.  */
  268.  
  269. FILE *asm_out_file;
  270. FILE *rtl_dump_file;
  271. FILE *jump_opt_dump_file;
  272. FILE *cse_dump_file;
  273. FILE *loop_dump_file;
  274. FILE *flow_dump_file;
  275. FILE *combine_dump_file;
  276. FILE *local_reg_dump_file;
  277. FILE *global_reg_dump_file;
  278. FILE *jump2_opt_dump_file;
  279.  
  280. /* Time accumulators, to count the total time spent in various passes.  */
  281.  
  282. int parse_time;
  283. int varconst_time;
  284. int integration_time;
  285. int jump_time;
  286. int cse_time;
  287. int loop_time;
  288. int flow_time;
  289. int combine_time;
  290. int local_alloc_time;
  291. int global_alloc_time;
  292. int final_time;
  293. int symout_time;
  294. int dump_time;
  295.  
  296. /* Return time used so far, in microseconds.  */
  297.  
  298. int
  299. gettime ()
  300. {
  301. #ifdef atarist
  302.   long now;
  303. #else
  304. #ifdef USG
  305.   struct tms tms;
  306. #else
  307. #ifndef VMS
  308.   struct rusage rusage;
  309. #else /* VMS */
  310.   struct
  311.     {
  312.       int proc_user_time;
  313.       int proc_system_time;
  314.       int child_user_time;
  315.       int child_system_time;
  316.     } vms_times;
  317. #endif
  318. #endif
  319. #endif        /* atarist */
  320.  
  321.   if (quiet_flag)
  322.     return 0;
  323.  
  324. #ifdef atarist
  325.   return(time(NULL) * 1000000);
  326. #else
  327. #ifdef USG
  328.   times (&tms);
  329.   return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
  330. #else
  331. #ifndef VMS
  332.   getrusage (0, &rusage);
  333.   return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
  334.       + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
  335. #else /* VMS */
  336.   times (&vms_times);
  337.   return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
  338. #endif
  339. #endif
  340. #endif        /* atarist */
  341. }
  342.  
  343. #define TIMEVAR(VAR, BODY)    \
  344. do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0)
  345.  
  346. void
  347. print_time (str, total)
  348.      char *str;
  349.      int total;
  350. {
  351.   fprintf (stderr,
  352.        "time in %s: %d.%06d\n",
  353.        str, total / 1000000, total % 1000000);
  354. }
  355.  
  356. /* Count an error or warning.  Return 1 if the message should be printed.  */
  357.  
  358. int
  359. count_error (warningp)
  360.      int warningp;
  361. {
  362.   if (warningp && inhibit_warnings)
  363.     return 0;
  364.  
  365.   if (warningp)
  366.     warningcount++;
  367.   else
  368.     errorcount++;
  369.  
  370.   return 1;
  371. }
  372.  
  373. /* Print a fatal error message.  NAME is the text.
  374.    Also include a system error message based on `errno'.  */
  375.  
  376. void
  377. pfatal_with_name (name)
  378.      char *name;
  379. {
  380.   fprintf (stderr, "cc1: ");
  381.   perror (name);
  382.   exit (35);
  383. }
  384.  
  385. void
  386. fatal_io_error (name)
  387.      char *name;
  388. {
  389.   fprintf (stderr, "cc1:%s: I/O error\n", name);
  390.   exit (35);
  391. }
  392.  
  393. void
  394. fatal (s)
  395.      char *s;
  396. {
  397.   error (s, 0);
  398.   exit (34);
  399. }
  400.  
  401. /* Called when the start of a function definition is parsed,
  402.    this function prints on stderr the name of the function.  */
  403.  
  404. void
  405. announce_function (decl)
  406.      tree decl;
  407. {
  408.   if (! quiet_flag)
  409.     {
  410.       fprintf (stderr, " %s", IDENTIFIER_POINTER (DECL_NAME (decl)));
  411.       fflush (stderr);
  412.     }
  413. }
  414.  
  415. /* Prints out, if necessary, the name of the current function
  416.    which caused an error.  Called from all error and warning functions.  */
  417.  
  418. void
  419. report_error_function()
  420. {
  421.   static tree last_error_function = NULL;
  422.  
  423.   if (last_error_function != current_function_decl)
  424.     {
  425.       if (current_function_decl == NULL)
  426.     {
  427.       if (!quiet_flag)
  428.         fprintf (stderr, "\n");
  429.       fprintf (stderr, "At top level:\n");
  430.     }
  431.       else
  432.     {
  433.       if (!quiet_flag)
  434.         /* We already know this info.  Don't print it twice.
  435.            But make sure we are at the beginning of a line.  */
  436.         fprintf (stderr, "\n");
  437.       else
  438.         fprintf (stderr, "In function %s:\n",
  439.              IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
  440.     }
  441.       last_error_function = current_function_decl;
  442.     }
  443. }
  444.  
  445. /* Report an error at the current line number.
  446.    S and V are a string and an arg for `printf'.  */
  447.  
  448. void
  449. error (s, v)
  450.      char *s;
  451.      int v;            /* @@also used as pointer */
  452. {
  453.   error_with_file_and_line (input_filename, lineno, s, v);
  454. }
  455.  
  456. /* Report an error at line LINE of file FILE.
  457.    S and V are a string and an arg for `printf'.  */
  458.  
  459. void
  460. error_with_file_and_line (file, line, s, v)
  461.      char *file;
  462.      int line;
  463.      char *s;
  464.      int v;
  465. {
  466.   count_error (0);
  467.  
  468.   report_error_function ();
  469.  
  470.   if (file)
  471.     fprintf (stderr, "%s:%d: ", file, line);
  472.   else
  473.     fprintf (stderr, "cc1: ");
  474.   fprintf (stderr, s, v);
  475.   fprintf (stderr, "\n");
  476. }
  477.  
  478. /* Report an error at the declaration DECL.
  479.    S is string which uses %s to substitute the declaration name.  */
  480.  
  481. void
  482. error_with_decl (decl, s)
  483.      tree decl;
  484.      char *s;
  485. {
  486.   count_error (0);
  487.  
  488.   report_error_function ();
  489.  
  490.   fprintf (stderr, "%s:%d: ",
  491.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  492.  
  493.   if (DECL_NAME (decl))
  494.     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)));
  495.   else
  496.     fprintf (stderr, s, "((anonymous))");
  497.   fprintf (stderr, "\n");
  498. }
  499.  
  500. /* Report a warning at line LINE.
  501.    S and V are a string and an arg for `printf'.  */
  502.  
  503. void
  504. warning_with_line (line, s, v)
  505.      int line;
  506.      char *s;
  507.      int v;
  508. {
  509.   if (count_error (1) == 0)
  510.     return;
  511.  
  512.   report_error_function ();
  513.  
  514.   if (input_filename)
  515.     fprintf (stderr, "%s:%d: ", input_filename, line);
  516.   else
  517.     fprintf (stderr, "cc1: ");
  518.  
  519.   fprintf (stderr, "warning: ");
  520.   fprintf (stderr, s, v);
  521.   fprintf (stderr, "\n");
  522. }
  523.  
  524. /* Report a warning at the current line number.
  525.    S and V are a string and an arg for `printf'.  */
  526.  
  527. void
  528. warning (s, v)
  529.      char *s;
  530.      int v;            /* @@also used as pointer */
  531. {
  532.   warning_with_line (lineno, s, v);
  533. }
  534.  
  535. /* Report a warning at the declaration DECL.
  536.    S is string which uses %s to substitute the declaration name.  */
  537.  
  538. void
  539. warning_with_decl (decl, s)
  540.      tree decl;
  541.      char *s;
  542. {
  543.   if (count_error (1) == 0)
  544.     return;
  545.  
  546.   report_error_function ();
  547.  
  548.   fprintf (stderr, "%s:%d: ",
  549.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  550.  
  551.   fprintf (stderr, "warning: ");
  552.   if (DECL_NAME (decl))
  553.     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)));
  554.   else
  555.     fprintf (stderr, s, "((anonymous))");
  556.   fprintf (stderr, "\n");
  557. }
  558.  
  559. /* When `malloc.c' is compiled with `rcheck' defined,
  560.    it calls this function to report clobberage.  */
  561.  
  562. void
  563. botch (s)
  564. {
  565.   abort ();
  566. }
  567.  
  568. /* Same as `malloc' but report error if no memory available.  */
  569.  
  570. int
  571. xmalloc (size)
  572.      unsigned size;
  573. {
  574.   register int value = (int) malloc (size);
  575.   if (value == 0)
  576.     fatal ("Virtual memory exhausted.");
  577.   return value;
  578. }
  579.  
  580. /* Same as `realloc' but report error if no memory available.  */
  581.  
  582. int
  583. xrealloc (ptr, size)
  584.      char *ptr;
  585.      int size;
  586. {
  587.   int result = realloc (ptr, size);
  588.   if (!result)
  589.     fatal ("Virtual memory exhausted.");
  590.   return result;
  591. }
  592.  
  593. /* Return the logarithm of X, base 2, considering X unsigned,
  594.    if X is a power of 2.  Otherwise, returns -1.  */
  595.  
  596. int
  597. exact_log2 (x)
  598.      register unsigned int x;
  599. {
  600.   register int log = 0;
  601.   for (log = 0; log < HOST_BITS_PER_INT; log++)
  602.     if (x == (1 << log))
  603.       return log;
  604.   return -1;
  605. }
  606.  
  607. /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
  608.    If X is 0, return -1.  */
  609.  
  610. int
  611. floor_log2 (x)
  612.      register unsigned int x;
  613. {
  614.   register int log = 0;
  615.   for (log = 0; log < HOST_BITS_PER_INT; log++)
  616.     if ((x & ((-1) << log)) == 0)
  617.       return log - 1;
  618.   return HOST_BITS_PER_INT - 1;
  619. }
  620.  
  621. /* Compile an entire file of output from cpp, named NAME.
  622.    Write a file of assembly output and various debugging dumps.  */
  623.  
  624. static void
  625. compile_file (name)
  626.      char *name;
  627. {
  628.   tree globals;
  629.   int start_time;
  630.   int dump_base_name_length = strlen (dump_base_name);
  631.  
  632.   parse_time = 0;
  633.   varconst_time = 0;
  634.   integration_time = 0;
  635.   jump_time = 0;
  636.   cse_time = 0;
  637.   loop_time = 0;
  638.   flow_time = 0;
  639.   combine_time = 0;
  640.   local_alloc_time = 0;
  641.   global_alloc_time = 0;
  642.   final_time = 0;
  643.   symout_time = 0;
  644.   dump_time = 0;
  645.  
  646.   /* Open input file.  */
  647.  
  648.   finput = fopen (name, "r");
  649.   if (finput == 0)
  650.     pfatal_with_name (name);
  651.  
  652.   /* Initialize data in various passes.  */
  653.  
  654.   init_tree ();
  655.   init_lex ();
  656.   init_rtl ();
  657.   init_emit_once ();
  658.   init_decl_processing ();
  659.   init_optabs ();
  660.  
  661.   /* If rtl dump desired, open the output file.  */
  662.   if (rtl_dump)
  663.     {
  664.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  665.       strcpy (dumpname, dump_base_name);
  666.       strcat (dumpname, ".rtl");
  667.       rtl_dump_file = fopen (dumpname, "w");
  668.       if (rtl_dump_file == 0)
  669.     pfatal_with_name (dumpname);
  670.     }
  671.  
  672.   /* If jump_opt dump desired, open the output file.  */
  673.   if (jump_opt_dump)
  674.     {
  675.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  676.       strcpy (dumpname, dump_base_name);
  677.       strcat (dumpname, ".jump");
  678.       jump_opt_dump_file = fopen (dumpname, "w");
  679.       if (jump_opt_dump_file == 0)
  680.     pfatal_with_name (dumpname);
  681.     }
  682.  
  683.   /* If cse dump desired, open the output file.  */
  684.   if (cse_dump)
  685.     {
  686.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  687.       strcpy (dumpname, dump_base_name);
  688.       strcat (dumpname, ".cse");
  689.       cse_dump_file = fopen (dumpname, "w");
  690.       if (cse_dump_file == 0)
  691.     pfatal_with_name (dumpname);
  692.     }
  693.  
  694.   /* If loop dump desired, open the output file.  */
  695.   if (loop_dump)
  696.     {
  697.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  698.       strcpy (dumpname, dump_base_name);
  699.       strcat (dumpname, ".loop");
  700.       loop_dump_file = fopen (dumpname, "w");
  701.       if (loop_dump_file == 0)
  702.     pfatal_with_name (dumpname);
  703.     }
  704.  
  705.   /* If flow dump desired, open the output file.  */
  706.   if (flow_dump)
  707.     {
  708.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  709.       strcpy (dumpname, dump_base_name);
  710.       strcat (dumpname, ".flow");
  711.       flow_dump_file = fopen (dumpname, "w");
  712.       if (flow_dump_file == 0)
  713.     pfatal_with_name (dumpname);
  714.     }
  715.  
  716.   /* If combine dump desired, open the output file.  */
  717.   if (combine_dump)
  718.     {
  719.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
  720.       strcpy (dumpname, dump_base_name);
  721.       strcat (dumpname, ".combine");
  722.       combine_dump_file = fopen (dumpname, "w");
  723.       if (combine_dump_file == 0)
  724.     pfatal_with_name (dumpname);
  725.     }
  726.  
  727.   /* If local_reg dump desired, open the output file.  */
  728.   if (local_reg_dump)
  729.     {
  730.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  731.       strcpy (dumpname, dump_base_name);
  732.       strcat (dumpname, ".lreg");
  733.       local_reg_dump_file = fopen (dumpname, "w");
  734.       if (local_reg_dump_file == 0)
  735.     pfatal_with_name (dumpname);
  736.     }
  737.  
  738.   /* If global_reg dump desired, open the output file.  */
  739.   if (global_reg_dump)
  740.     {
  741.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  742.       strcpy (dumpname, dump_base_name);
  743.       strcat (dumpname, ".greg");
  744.       global_reg_dump_file = fopen (dumpname, "w");
  745.       if (global_reg_dump_file == 0)
  746.     pfatal_with_name (dumpname);
  747.     }
  748.  
  749.   /* If jump2_opt dump desired, open the output file.  */
  750.   if (jump2_opt_dump)
  751.     {
  752.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  753.       strcpy (dumpname, dump_base_name);
  754.       strcat (dumpname, ".jump2");
  755.       jump2_opt_dump_file = fopen (dumpname, "w");
  756.       if (jump2_opt_dump_file == 0)
  757.     pfatal_with_name (dumpname);
  758.     }
  759.  
  760.   /* Open assembler code output file.  */
  761.  
  762.   {
  763.     register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  764.     int len = strlen (dump_base_name);
  765.     strcpy (dumpname, dump_base_name);
  766.     if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  767.       dumpname[len - 2] = 0;
  768.     else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  769.       dumpname[len - 3] = 0;
  770.     strcat (dumpname, ".s");
  771.     if (asm_file_name == 0)
  772.       {
  773.     asm_file_name = (char *) malloc (strlen (dumpname) + 1);
  774.     strcpy (asm_file_name, dumpname);
  775.       }
  776.     asm_out_file = fopen (asm_file_name, "w");
  777.     if (asm_out_file == 0)
  778.       pfatal_with_name (asm_file_name ? asm_file_name : dumpname);
  779.   }
  780.  
  781.   input_filename = name;
  782.  
  783.   /* the beginning of the file is a new line; check for # */
  784.   /* With luck, we discover the real source file's name from that
  785.      and put it in input_filename.  */
  786.   ungetc (check_newline (), finput);
  787.  
  788.   ASM_FILE_START (asm_out_file);
  789.  
  790.   /* If GDB symbol table desired, open the GDB symbol output file.  */
  791.   if (write_symbols == GDB_DEBUG)
  792.     {
  793.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  794.       int len = strlen (dump_base_name);
  795.       strcpy (dumpname, dump_base_name);
  796.       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  797.     dumpname[len - 2] = 0;
  798.       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  799.     dumpname[len - 3] = 0;
  800.       strcat (dumpname, ".sym");
  801.       if (sym_file_name == 0)
  802.     sym_file_name = dumpname;
  803.       symout_init (sym_file_name, asm_out_file, main_input_filename);
  804.     }
  805.  
  806.   /* If dbx symbol table desired, initialize writing it
  807.      and output the predefined types.  */
  808. #ifdef DBX_DEBUGGING_INFO
  809.   if (write_symbols == DBX_DEBUG)
  810.     dbxout_init (asm_out_file, main_input_filename);
  811. #endif
  812. #ifdef SDB_DEBUGGING_INFO
  813.   if (write_symbols == SDB_DEBUG)
  814.     sdbout_init (asm_out_file, main_input_filename);
  815. #endif
  816.  
  817.   /* Initialize yet another pass.  */
  818.  
  819.   init_final (main_input_filename);
  820.  
  821.   start_time = gettime ();
  822.  
  823.   /* Call the parser, which parses the entire file
  824.      (calling rest_of_compilation for each function).  */
  825.  
  826.   yyparse ();
  827.  
  828.   /* Compilation is now finished except for writing
  829.      what's left of the symbol table output.  */
  830.  
  831.   parse_time += gettime () - start_time;
  832.  
  833.   parse_time -= varconst_time;
  834.  
  835.   globals = getdecls ();
  836.  
  837.   /* Really define vars that have had only a tentative definition.
  838.      Really output inline functions that must actually be callable
  839.      and have not been output so far.  */
  840.  
  841.   {
  842.     tree decl;
  843.     for (decl = globals; decl; decl = TREE_CHAIN (decl))
  844.       {
  845.     if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
  846.         && ! TREE_ASM_WRITTEN (decl))
  847.       rest_of_decl_compilation (decl, 0, 1, 1);
  848.     if (TREE_CODE (decl) == FUNCTION_DECL
  849.         && ! TREE_ASM_WRITTEN (decl)
  850.         && DECL_INITIAL (decl) != 0
  851.         && TREE_ADDRESSABLE (decl))
  852.       output_inline_function (decl);
  853.       }
  854.   }
  855.  
  856.   /* Do dbx symbols */
  857. #ifdef DBX_DEBUGGING_INFO
  858.   if (write_symbols == DBX_DEBUG)
  859.     TIMEVAR (symout_time,
  860.          {
  861.            dbxout_tags (gettags ());
  862.            dbxout_types (get_permanent_types ());
  863.          });
  864. #endif
  865.  
  866. #ifdef SDB_DEBUGGING_INFO
  867.   if (write_symbols == SDB_DEBUG)
  868.     TIMEVAR (symout_time,
  869.          {
  870.            sdbout_tags (gettags ());
  871.            sdbout_types (get_permanent_types ());
  872.          });
  873. #endif
  874.  
  875.   /* Do gdb symbols */
  876.   if (write_symbols == GDB_DEBUG)
  877.     TIMEVAR (symout_time,
  878.          {
  879.            struct stat statbuf;
  880. #ifdef atarist
  881.         stat (name, &statbuf);
  882. #else
  883.            fstat (fileno (finput), &statbuf);
  884. #endif
  885.            symout_types (get_permanent_types ());
  886.            symout_top_blocks (globals, gettags ());
  887.            symout_finish (name, statbuf.st_ctime);
  888.          });
  889.  
  890.   /* Close the dump files.  */
  891.  
  892.   if (rtl_dump)
  893.     fclose (rtl_dump_file);
  894.  
  895.   if (jump_opt_dump)
  896.     fclose (jump_opt_dump_file);
  897.  
  898.   if (cse_dump)
  899.     fclose (cse_dump_file);
  900.  
  901.   if (loop_dump)
  902.     fclose (loop_dump_file);
  903.  
  904.   if (flow_dump)
  905.     fclose (flow_dump_file);
  906.  
  907.   if (combine_dump)
  908.     {
  909.       dump_combine_total_stats (combine_dump_file);
  910.       fclose (combine_dump_file);
  911.     }
  912.  
  913.   if (local_reg_dump)
  914.     fclose (local_reg_dump_file);
  915.  
  916.   if (global_reg_dump)
  917.     fclose (global_reg_dump_file);
  918.  
  919.   if (jump2_opt_dump)
  920.     fclose (jump2_opt_dump_file);
  921.  
  922.   /* Close non-debugging input and output files.  */
  923.  
  924.   fclose (finput);
  925.   if (ferror (asm_out_file) != 0)
  926.     fatal_io_error (asm_file_name);
  927.   fclose (asm_out_file);
  928.  
  929.   /* Print the times.  */
  930.  
  931.   if (! quiet_flag)
  932.     {
  933.       fprintf (stderr,"\n");
  934.       print_time ("parse", parse_time);
  935.       print_time ("integration", integration_time);
  936.       print_time ("jump", jump_time);
  937.       print_time ("cse", cse_time);
  938.       print_time ("loop", loop_time);
  939.       print_time ("flow", flow_time);
  940.       print_time ("combine", combine_time);
  941.       print_time ("local-alloc", local_alloc_time);
  942.       print_time ("global-alloc", global_alloc_time);
  943.       print_time ("final", final_time);
  944.       print_time ("varconst", varconst_time);
  945.       print_time ("symout", symout_time);
  946.       print_time ("dump", dump_time);
  947.     }
  948. }
  949.  
  950. /* This is called from finish_decl (within yyparse)
  951.    for each declaration of a function or variable.
  952.    This does nothing for automatic variables.
  953.    Otherwise, it sets up the RTL and outputs any assembler code
  954.    (label definition, storage allocation and initialization).
  955.  
  956.    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
  957.    the assembler symbol name to be used.  TOP_LEVEL is nonzero
  958.    if this declaration is not within a function.  */
  959.  
  960. void
  961. rest_of_decl_compilation (decl, asmspec, top_level, at_end)
  962.      tree decl;
  963.      tree asmspec;
  964.      int top_level;
  965.      int at_end;
  966. {
  967.   /* Declarations of variables, and of functions defined elsewhere.  */
  968.  
  969.   if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
  970.     TIMEVAR (varconst_time,
  971.          {
  972.            assemble_variable (decl, asmspec, top_level, write_symbols, at_end);
  973.          });
  974. #ifdef DBX_DEBUGGING_INFO
  975.   else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  976.     TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
  977. #endif
  978. #ifdef SDB_DEBUGGING_INFO
  979.   else if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  980.     TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
  981. #endif
  982.  
  983.   if (top_level)
  984.     {
  985.       if (write_symbols == GDB_DEBUG)
  986.     {
  987.       TIMEVAR (symout_time,
  988.            {
  989.              /* The initizations make types when they contain
  990.             string constants.  The types are on the temporary
  991.             obstack, so output them now before they go away.  */
  992.              symout_types (get_temporary_types ());
  993.            });
  994.     }
  995.       else
  996.     /* Clean out the temporary type list, since the types will go away.  */
  997.     get_temporary_types ();
  998.     }
  999. }
  1000.  
  1001. /* This is called from finish_function (within yyparse)
  1002.    after each top-level definition is parsed.
  1003.    It is supposed to compile that function or variable
  1004.    and output the assembler code for it.
  1005.    After we return, the tree storage is freed.  */
  1006.  
  1007. void
  1008. rest_of_compilation (decl)
  1009.      tree decl;
  1010. {
  1011.   register rtx insns;
  1012.   int start_time = gettime ();
  1013.   int tem;
  1014.  
  1015.   /* If we are reconsidering an inline function
  1016.      at the end of compilation, skip the stuff for making it inline.  */
  1017.  
  1018.   if (DECL_SAVED_INSNS (decl) == 0)
  1019.     {
  1020.  
  1021.       /* If requested, consider whether to make this function inline.  */
  1022.       if (flag_inline_functions || TREE_INLINE (decl))
  1023.     {
  1024.       TIMEVAR (integration_time,
  1025.            {
  1026.              int specd = TREE_INLINE (decl);
  1027.              char *lose = function_cannot_inline_p (decl);
  1028.              if (lose != 0 && specd)
  1029.                warning_with_decl (decl, lose);
  1030.              if (lose == 0)
  1031.                save_for_inline (decl);
  1032.              else
  1033.                TREE_INLINE (decl) = 0;
  1034.            });
  1035.     }
  1036.  
  1037.       insns = get_insns ();
  1038.  
  1039.       /* Dump the rtl code if we are dumping rtl.  */
  1040.  
  1041.       if (rtl_dump)
  1042.     TIMEVAR (dump_time,
  1043.          {
  1044.            fprintf (rtl_dump_file, "\n;; Function %s\n\n",
  1045.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  1046.            if (DECL_SAVED_INSNS (decl))
  1047.              fprintf (rtl_dump_file, ";; (integrable)\n\n");
  1048.            print_rtl (rtl_dump_file, insns);
  1049.            fflush (rtl_dump_file);
  1050.          });
  1051.  
  1052.       /* If function is inline, and we don't yet know whether to
  1053.      compile it by itself, defer decision till end of compilation.
  1054.      finish_compilation will call rest_of_compilation again
  1055.      for those functions that need to be output.  */
  1056.  
  1057.       if (TREE_PUBLIC (decl) == 0
  1058.       && TREE_INLINE (decl)
  1059.       && ! flag_keep_inline_functions)
  1060.     goto exit_rest_of_compilation;
  1061.     }
  1062.  
  1063.   if (rtl_dump_and_exit)
  1064.     goto exit_rest_of_compilation;
  1065.  
  1066.   TREE_ASM_WRITTEN (decl) = 1;
  1067.  
  1068.   insns = get_insns ();
  1069.  
  1070.   /* Copy any shared structure that should not be shared.  */
  1071.  
  1072.   unshare_all_rtl (insns);
  1073.  
  1074.   /* See if we have allocated stack slots that are not directly addressable.
  1075.      If so, scan all the insns and create explicit address computation
  1076.      for all references to such slots.  */
  1077. /*   fixup_stack_slots (); */
  1078.  
  1079.   /* Do jump optimization the first time, if -opt.
  1080.      Also do it if -W, but in that case it doesn't change the rtl code,
  1081.      it only computes whether control can drop off the end of the function.  */
  1082.  
  1083.   if (optimize || extra_warnings || warn_return_type)
  1084.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1085.  
  1086.   /* Dump rtl code after jump, if we are doing that.  */
  1087.  
  1088.   if (jump_opt_dump)
  1089.     TIMEVAR (dump_time,
  1090.          {
  1091.            fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
  1092.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1093.            print_rtl (jump_opt_dump_file, insns);
  1094.            fflush (jump_opt_dump_file);
  1095.          });
  1096.  
  1097.   /* Perform common subexpression elimination.
  1098.      Nonzero value from `cse_main' means that jumps were simplified
  1099.      and some code may now be unreachable, so do
  1100.      jump optimization again.  */
  1101.  
  1102.   if (optimize)
  1103.     {
  1104.       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
  1105.  
  1106.       TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
  1107.  
  1108.       if (tem)
  1109.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1110.     }
  1111.  
  1112.   /* Dump rtl code after cse, if we are doing that.  */
  1113.  
  1114.   if (cse_dump)
  1115.     TIMEVAR (dump_time,
  1116.          {
  1117.            fprintf (cse_dump_file, "\n;; Function %s\n\n",
  1118.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1119.            print_rtl (cse_dump_file, insns);
  1120.            fflush (cse_dump_file);
  1121.          });
  1122.  
  1123.   if (loop_dump)
  1124.     TIMEVAR (dump_time,
  1125.          {
  1126.            fprintf (loop_dump_file, "\n;; Function %s\n\n",
  1127.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1128.          });
  1129.  
  1130.   /* Move constant computations out of loops.  */
  1131.  
  1132.   if (optimize)
  1133.     {
  1134.       TIMEVAR (loop_time,
  1135.            {
  1136.          reg_scan (insns, max_reg_num (), 1);
  1137.          loop_optimize (insns, max_reg_num (),
  1138.                 loop_dump ? loop_dump_file : 0);
  1139.            });
  1140.     }
  1141.  
  1142.   /* Dump rtl code after loop opt, if we are doing that.  */
  1143.  
  1144.   if (loop_dump)
  1145.     TIMEVAR (dump_time,
  1146.          {
  1147.            print_rtl (loop_dump_file, insns);
  1148.            fflush (loop_dump_file);
  1149.          });
  1150.  
  1151.   /* Now we choose between stupid (pcc-like) register allocation
  1152.      (if we got the -noreg switch and not -opt)
  1153.      and smart register allocation.  */
  1154.  
  1155.   if (optimize)        /* Stupid allocation probably won't work */
  1156.     obey_regdecls = 0;    /* if optimizations being done.  */
  1157.  
  1158.   regclass_init ();
  1159.  
  1160.   /* Print function header into flow dump now
  1161.      because doing the flow analysis makes some of the dump.  */
  1162.  
  1163.   if (flow_dump)
  1164.     TIMEVAR (dump_time,
  1165.          {
  1166.            fprintf (flow_dump_file, "\n;; Function %s\n\n",
  1167.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1168.          });
  1169.  
  1170.   if (obey_regdecls)
  1171.     {
  1172.       TIMEVAR (flow_time,
  1173.            {
  1174.          regclass (insns, max_reg_num ());
  1175.          stupid_life_analysis (insns, max_reg_num (),
  1176.                        flow_dump_file);
  1177.            });
  1178.     }
  1179.   else
  1180.     {
  1181.       /* Do control and data flow analysis,
  1182.      and write some of the results to dump file.  */
  1183.  
  1184.       TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
  1185.                      flow_dump_file));
  1186.       if (extra_warnings)
  1187.     uninitialized_vars_warning (DECL_INITIAL (decl));
  1188.     }
  1189.  
  1190.   /* Dump rtl after flow analysis.  */
  1191.  
  1192.   if (flow_dump)
  1193.     TIMEVAR (dump_time,
  1194.          {
  1195.            print_rtl (flow_dump_file, insns);
  1196.            fflush (flow_dump_file);
  1197.          });
  1198.  
  1199.   /* If -opt, try combining insns through substitution.  */
  1200.  
  1201.   if (optimize)
  1202.     TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
  1203.  
  1204.   /* Dump rtl code after insn combination.  */
  1205.  
  1206.   if (combine_dump)
  1207.     TIMEVAR (dump_time,
  1208.          {
  1209.            fprintf (combine_dump_file, "\n;; Function %s\n\n",
  1210.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1211.            dump_combine_stats (combine_dump_file);
  1212.            print_rtl (combine_dump_file, insns);
  1213.            fflush (combine_dump_file);
  1214.          });
  1215.  
  1216.   /* Unless we did stupid register allocation,
  1217.      allocate pseudo-regs that are used only within 1 basic block.  */
  1218.  
  1219.   if (!obey_regdecls)
  1220.     TIMEVAR (local_alloc_time,
  1221.          {
  1222.            regclass (insns, max_reg_num ());
  1223.            local_alloc ();
  1224.          });
  1225.  
  1226.   /* Dump rtl code after allocating regs within basic blocks.  */
  1227.  
  1228.   if (local_reg_dump)
  1229.     TIMEVAR (dump_time,
  1230.          {
  1231.            fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
  1232.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1233.            dump_flow_info (local_reg_dump_file);
  1234.            dump_local_alloc (local_reg_dump_file);
  1235.            print_rtl (local_reg_dump_file, insns);
  1236.            fflush (local_reg_dump_file);
  1237.          });
  1238.  
  1239.   if (global_reg_dump)
  1240.     TIMEVAR (dump_time,
  1241.          fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
  1242.               IDENTIFIER_POINTER (DECL_NAME (decl))));
  1243.  
  1244.   /* Unless we did stupid register allocation,
  1245.      allocate remaining pseudo-regs, then do the reload pass
  1246.      fixing up any insns that are invalid.  */
  1247.  
  1248.   TIMEVAR (global_alloc_time,
  1249.        {
  1250.          if (!obey_regdecls)
  1251.            global_alloc (global_reg_dump ? global_reg_dump_file : 0);
  1252.          else
  1253.            reload (insns, 0,
  1254.                global_reg_dump ? global_reg_dump_file : 0);
  1255.        });
  1256.  
  1257.   if (global_reg_dump)
  1258.     TIMEVAR (dump_time,
  1259.          {
  1260.            dump_global_regs (global_reg_dump_file);
  1261.            print_rtl (global_reg_dump_file, insns);
  1262.            fflush (global_reg_dump_file);
  1263.          });
  1264.  
  1265.   /* One more attempt to remove jumps to .+1
  1266.      left by dead-store-elimination.
  1267.      Also do cross-jumping this time
  1268.      and delete no-op move insns.  */
  1269.  
  1270.   if (optimize)
  1271.     {
  1272.       TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
  1273.     }
  1274.  
  1275.   /* Dump rtl code after jump, if we are doing that.  */
  1276.  
  1277.   if (jump2_opt_dump)
  1278.     TIMEVAR (dump_time,
  1279.          {
  1280.            fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
  1281.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1282.            print_rtl (jump2_opt_dump_file, insns);
  1283.            fflush (jump2_opt_dump_file);
  1284.          });
  1285.  
  1286.   /* Now turn the rtl into assembler code.  */
  1287.  
  1288.   TIMEVAR (final_time,
  1289.        {
  1290.          assemble_function (decl);
  1291.          final_start_function (insns, asm_out_file,
  1292.                    write_symbols, optimize);
  1293.          final (insns, asm_out_file,
  1294.             write_symbols, optimize);
  1295.          final_end_function (insns, asm_out_file,
  1296.                  write_symbols, optimize);
  1297.          fflush (asm_out_file);
  1298.        });
  1299.  
  1300.   /* Write GDB symbols if requested */
  1301.  
  1302.   if (write_symbols == GDB_DEBUG)
  1303.     {
  1304.       TIMEVAR (symout_time,
  1305.            {
  1306.          symout_types (get_permanent_types ());
  1307.          symout_types (get_temporary_types ());
  1308.  
  1309.          DECL_BLOCK_SYMTAB_ADDRESS (decl)
  1310.            = symout_function (DECL_INITIAL (decl),
  1311.                       DECL_ARGUMENTS (decl), 0);
  1312.            });
  1313.     }
  1314.   else
  1315.     get_temporary_types ();
  1316.  
  1317.   /* Write DBX symbols if requested */
  1318.  
  1319. #ifdef DBX_DEBUGGING_INFO
  1320.   if (write_symbols == DBX_DEBUG)
  1321.     TIMEVAR (symout_time, dbxout_function (decl));
  1322. #endif
  1323.  
  1324.  exit_rest_of_compilation:
  1325.  
  1326.   /* The parsing time is all the time spent in yyparse
  1327.      *except* what is spent in this function.  */
  1328.  
  1329.   parse_time -= gettime () - start_time;
  1330. }
  1331.  
  1332. /* Entry point of cc1.  Decode command args, then call compile_file.
  1333.    Exit code is 35 if can't open files, 34 if fatal error,
  1334.    33 if had nonfatal errors, else success.  */
  1335.  
  1336. int
  1337. main (argc, argv, envp)
  1338.      int argc;
  1339.      char **argv;
  1340.      char **envp;
  1341. {
  1342.   register int i;
  1343.   char *filename = 0;
  1344.   int print_mem_flag = 0;
  1345.  
  1346. #ifdef RLIMIT_STACK
  1347.   /* Get rid of any avoidable limit on stack size.  */
  1348.   {
  1349.     struct rlimit rlim;
  1350.  
  1351.     /* Set the stack limit huge so that alloca does not fail. */
  1352.     getrlimit (RLIMIT_STACK, &rlim);
  1353.     rlim.rlim_cur = rlim.rlim_max;
  1354.     setrlimit (RLIMIT_STACK, &rlim);
  1355.   }
  1356. #endif /* RLIMIT_STACK */
  1357.  
  1358.   /* Initialize whether `char' is signed.  */
  1359.   flag_signed_char = DEFAULT_SIGNED_CHAR;
  1360.  
  1361.   /* This is zeroed by -O.  */
  1362.   obey_regdecls = 1;
  1363.  
  1364.   /* Initialize register usage now so switches may override.  */
  1365.   init_reg_sets ();
  1366.  
  1367.   target_flags = 0;
  1368.   set_target_switch ("");
  1369.  
  1370.   for (i = 1; i < argc; i++)
  1371.     if (argv[i][0] == '-')
  1372.       {
  1373.     register char *str = argv[i] + 1;
  1374.     if (str[0] == 'Y')
  1375.       str++;
  1376.  
  1377.     if (str[0] == 'm')
  1378.       set_target_switch (&str[1]);
  1379.     else if (!strcmp (str, "dumpbase"))
  1380.       {
  1381.         dump_base_name = argv[++i];
  1382. #ifdef atarist
  1383. /* dump_base_name will typically be 'foo.c' here.  Need to truncate at the '.',
  1384.    cause dots mean something here */
  1385.         {
  1386.           char * n = dump_base_name;
  1387.           for ( ; ((*n) && (*n != '.')) ; )
  1388.         n++;
  1389.           *n = '\0';
  1390.         }
  1391. #endif
  1392.       }
  1393.     else if (str[0] == 'd')
  1394.       {
  1395.         register char *p = &str[1];
  1396.         while (*p)
  1397.           switch (*p++)
  1398.         {
  1399.         case 'c':
  1400.           combine_dump = 1;
  1401.           break;
  1402.         case 'f':
  1403.           flow_dump = 1;
  1404.           break;
  1405.         case 'g':
  1406.           global_reg_dump = 1;
  1407.           break;
  1408.         case 'j':
  1409.           jump_opt_dump = 1;
  1410.           break;
  1411.         case 'J':
  1412.           jump2_opt_dump = 1;
  1413.           break;
  1414.         case 'l':
  1415.           local_reg_dump = 1;
  1416.           break;
  1417.         case 'L':
  1418.           loop_dump = 1;
  1419.           break;
  1420.         case 'm':
  1421.           print_mem_flag = 1;
  1422.           break;
  1423.         case 'r':
  1424.           rtl_dump = 1;
  1425.           break;
  1426.         case 's':
  1427.           cse_dump = 1;
  1428.           break;
  1429.         case 'y':
  1430.           yydebug = 1;
  1431.           break;
  1432.         }
  1433.       }
  1434.     else if (str[0] == 'f')
  1435.       {
  1436.         register char *p = &str[1];
  1437.         if (!strcmp (p, "float-store"))
  1438.           flag_float_store = 1;
  1439.         else if (!strcmp (p, "traditional"))
  1440.           flag_traditional = 1, dollars_in_ident = 1;
  1441.         else if (!strcmp (p, "volatile"))
  1442.           flag_volatile = 1;
  1443.         else if (!strcmp (p, "defer-pop"))
  1444.           flag_defer_pop = 1;
  1445.         else if (!strcmp (p, "no-defer-pop"))
  1446.           flag_defer_pop = 0;
  1447.         else if (!strcmp (p, "omit-frame-pointer"))
  1448.           flag_omit_frame_pointer = 1;
  1449.         else if (!strcmp (p, "no-omit-frame-pointer"))
  1450.           flag_omit_frame_pointer = 0;
  1451.         else if (!strcmp (p, "no-peephole"))
  1452.           flag_no_peephole = 1;
  1453.         else if (!strcmp (p, "signed-char"))
  1454.           flag_signed_char = 1;
  1455.         else if (!strcmp (p, "unsigned-char"))
  1456.           flag_signed_char = 0;
  1457.         else if (!strcmp (p, "force-mem"))
  1458.           flag_force_mem = 1;
  1459.         else if (!strcmp (p, "force-addr"))
  1460.           flag_force_addr = 1;
  1461.         else if (!strcmp (p, "combine-regs"))
  1462.           flag_combine_regs = 1;
  1463.         else if (!strcmp (p, "writable-strings"))
  1464.           flag_writable_strings = 1;
  1465.         else if (!strcmp (p, "no-function-cse"))
  1466.           flag_no_function_cse = 1;
  1467.         else if (!strcmp (p, "cond-mismatch"))
  1468.           flag_cond_mismatch = 1;
  1469.         else if (!strcmp (p, "no-asm"))
  1470.           flag_no_asm = 1;
  1471.         else if (!strncmp (p, "fixed-", 6))
  1472.           fix_register (&p[6], 1, 1);
  1473.         else if (!strncmp (p, "call-used-", 10))
  1474.           fix_register (&p[10], 0, 1);
  1475.         else if (!strncmp (p, "call-saved-", 11))
  1476.           fix_register (&p[11], 0, 0);
  1477.         else if (!strcmp (p, "inline-functions"))
  1478.           flag_inline_functions = 1;
  1479.         else if (!strcmp (p, "keep-inline-functions"))
  1480.           flag_keep_inline_functions = 1;
  1481.         else
  1482.           error ("Invalid option, `%s'", argv[i]);          
  1483.       }
  1484.     else if (!strcmp (str, "noreg"))
  1485.       ;
  1486.     else if (!strcmp (str, "opt"))
  1487.       optimize = 1, obey_regdecls = 0;
  1488.     else if (!strcmp (str, "O"))
  1489.       optimize = 1, obey_regdecls = 0;
  1490.     else if (!strcmp (str, "pedantic"))
  1491.       pedantic = 1;
  1492.     else if (!strcmp (str, "traditional"))
  1493.       flag_traditional = 1, dollars_in_ident = 1;
  1494.     else if (!strcmp (str, "ansi"))
  1495.       flag_no_asm = 1, dollars_in_ident = 0;
  1496.     else if (!strcmp (str, "quiet"))
  1497.       quiet_flag = 1;
  1498.     else if (!strcmp (str, "version"))
  1499.       {
  1500.         extern char *version_string;
  1501.         printf ("GNU C version %s", version_string);
  1502. #ifdef TARGET_VERSION
  1503.         TARGET_VERSION;
  1504. #endif
  1505. #ifdef __GNUC__
  1506. #ifndef __VERSION__
  1507. #define __VERSION__ "[unknown]"
  1508. #endif
  1509.         printf (" compiled by GNU C version %s.\n", __VERSION__);
  1510. #else
  1511.         printf (" compiled by CC.\n");
  1512. #endif
  1513.       }
  1514.     else if (!strcmp (str, "w"))
  1515.       inhibit_warnings = 1;
  1516.     else if (!strcmp (str, "W"))
  1517.       extra_warnings = 1;
  1518.     else if (!strcmp (str, "Wimplicit"))
  1519.       warn_implicit = 1;
  1520.     else if (!strcmp (str, "Wreturn-type"))
  1521.       warn_return_type = 1;
  1522.     else if (!strcmp (str, "Wcomment"))
  1523.       ; /* cpp handles this one.  */
  1524.     else if (!strcmp (str, "Wtrigraphs"))
  1525.       ; /* cpp handles this one.  */
  1526.     else if (!strcmp (str, "Wall"))
  1527.       {
  1528.         extra_warnings = 1;
  1529.         warn_implicit = 1;
  1530.         warn_return_type = 1;
  1531.       }
  1532.     else if (!strcmp (str, "p"))
  1533.       profile_flag = 1;
  1534.     else if (!strcmp (str, "gg"))
  1535.       write_symbols = GDB_DEBUG;
  1536. #ifdef DBX_DEBUGGING_INFO
  1537.     else if (!strcmp (str, "g"))
  1538.       write_symbols = DBX_DEBUG;
  1539.     else if (!strcmp (str, "G"))
  1540.       write_symbols = DBX_DEBUG;
  1541. #endif
  1542. #ifdef SDB_DEBUGGING_INFO
  1543.     else if (!strcmp (str, "g"))
  1544.       write_symbols = SDB_DEBUG;
  1545.     else if (!strcmp (str, "G"))
  1546.       write_symbols = SDB_DEBUG;
  1547. #endif
  1548.     else if (!strcmp (str, "symout"))
  1549.       {
  1550.         if (write_symbols == NO_DEBUG)
  1551.           write_symbols = GDB_DEBUG;
  1552.         sym_file_name = argv[++i];
  1553.       }
  1554.     else if (!strcmp (str, "o"))
  1555.       {
  1556.         asm_file_name = argv[++i];
  1557.       }
  1558.     else
  1559.       error ("Invalid switch, %s.", argv[i]);
  1560.       }
  1561.     else
  1562.       filename = argv[i];
  1563.  
  1564.   if (filename == 0)
  1565.     fatal ("no input file specified");
  1566.  
  1567.   if (dump_base_name == 0)
  1568.     dump_base_name = filename;
  1569.  
  1570. #ifdef OVERRIDE_OPTIONS
  1571.   /* Some machines may reject certain combinations of options.  */
  1572.   OVERRIDE_OPTIONS;
  1573. #endif
  1574.  
  1575.   /* Now that register usage is specified, convert it to HARD_REG_SETs.  */
  1576.   init_reg_sets_1 ();
  1577.  
  1578.   compile_file (filename);
  1579.  
  1580. #ifndef atarist
  1581. #ifndef USG
  1582. #ifndef VMS
  1583.   if (print_mem_flag)
  1584.     {
  1585.       extern char **environ;
  1586.       caddr_t lim = (caddr_t) sbrk (0);
  1587.       
  1588.       fprintf (stderr, "Data size %d.\n",
  1589.            (int) lim - (int) &environ);
  1590.       fflush (stderr);
  1591.  
  1592.       system ("ps v");
  1593.     }
  1594. #endif /* not VMS */
  1595. #endif /* not USG */
  1596. #endif /* not atarist */
  1597.  
  1598.   if (errorcount)
  1599.     exit (FATAL_EXIT_CODE);
  1600.   exit (SUCCESS_EXIT_CODE);
  1601.   return 34;
  1602. }
  1603.  
  1604. /* Decode -m switches.  */
  1605.  
  1606. /* Here is a table, controlled by the tm-...h file, listing each -m switch
  1607.    and which bits in `target_switches' it should set or clear.
  1608.    If VALUE is positive, it is bits to set.
  1609.    If VALUE is negative, -VALUE is bits to clear.
  1610.    (The sign bit is not used so there is no confusion.)  */
  1611.  
  1612. struct {char *name; int value;} target_switches []
  1613.   = TARGET_SWITCHES;
  1614.  
  1615. /* Decode the switch -mNAME.  */
  1616.  
  1617. void
  1618. set_target_switch (name)
  1619.      char *name;
  1620. {
  1621.   register int j;
  1622.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  1623.     if (!strcmp (target_switches[j].name, name))
  1624.       {
  1625.     if (target_switches[j].value < 0)
  1626.       target_flags &= ~-target_switches[j].value;
  1627.     else
  1628.       target_flags |= target_switches[j].value;
  1629.     break;
  1630.       }
  1631. }
  1632.